<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
    <script src="/static/js/echarts.js"></script>
    <script>
        $(function () {
            //获取下拉框场馆
            $.post(
                "/main/getBuilt",
                function (arr) {
                    for(var i in arr){
                        $("[name='bid']").append("<option value='"+arr[i].bid+"'>"+arr[i].bname+"</option>")
                    }
                    $("[name='bid']").val("${main.bid}")
                }
            )
            //获取下拉框项目类型
            $.post(
                "/main/getType",
                function (arr) {
                    for(var i in arr) {
                        $("[name='tid']").append("<option value='" + arr[i].tid + "'>" + arr[i].tname + "</option>")
                    }
                    $("[name='tid']").val("${main.tid}")
                }
            )
            //获取下拉框场地
            $.post(
                "/main/getGround",
                function (arr) {
                    for(var i in arr) {
                        $("[name='gid']").append("<option value='" + arr[i].gid + "'>" + arr[i].gname + "</option>")
                    }
                    $("[name='gid']").val("${main.gid}")
                }
            )
        })
    </script>
</head>
<body>
<center>
    <h1>列表页面</h1>
    当前用户:${username}<br>
    <a href="/main/toAdd">场馆设置</a>
    <a href="/main/toEcharts">统计报表</a>
    <form action="/main/list" method="post">
        场馆:<select name="bid">
        <option value="">请选择</option>
    </select>
        项目类型:<select name="tid">
        <option value="">请选择</option>
    </select>
        场地:<select name="gid">
        <option value="">请选择</option>
    </select>
        <button type="submit">搜索</button>
    </form>
    <table class="table">
        <tr>
            <td>场馆</td>
            <td>项目类型</td>
            <td>场地</td>
            <td>开始时间</td>
            <td>结束时间</td>
            <td>价格</td>
            <td>最新更新时间</td>
            <td>最近更新人</td>
        </tr>
        <c:forEach items="${pg.list}" var="li">
            <tr>
                <td>${li.bname}</td>
                <td>${li.tname}</td>
                <td>${li.gname}</td>
                <td>${li.startTime}</td>
                <td>${li.endTime}</td>
                <td>${li.price}</td>
                <td>
                    <fmt:formatDate value="${li.created}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
                </td>
                <td>${li.username}</td>
            </tr>
        </c:forEach>
    </table>
    <jsp:include page="/static/common/pages.jsp"></jsp:include>
</center>
</body>
</html>
